package edu.ustb.test.web;

import java.util.ArrayList;
import java.util.List;

public class FilterChain {
	
	List<Filter> filters = new ArrayList<Filter>();
	
	private int index = 0;
	
	public void doFilter(Request request,Response response,FilterChain filterChain) {
		if (index >= filters.size())
			return;
		Filter filter = filters.get(index);
		index++;
		filter.doFilter(request, response, filterChain);
		
	}
	
	public FilterChain addFilter(Filter filter) {
		filters.add(filter);
		return this;
	}
	
	
}
